home *** CD-ROM | disk | FTP | other *** search
- Path: news.halcyon.com!usenet
- From: normanb@halcyon.com (Norm Bryar)
- Newsgroups: comp.lang.c++
- Subject: Re: passing struct to constructor - temp.txt [1/1]
- Date: Tue, 12 Mar 1996 15:47:20 GMT
- Organization: Northwest Nexus Inc.
- Message-ID: <4i468t$pa7@news.halcyon.com>
- References: <4eqgq3$5g1@geraldo.cc.utexas.edu> <4hseh1$rkk@news2.delphi.com>
- NNTP-Posting-Host: blv-pm3-ip12.halcyon.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- JGUILLORY@delphi.com wrote:
-
-
- >Quoting wharris from a message in comp.lang.c++
- > wh>The compiler error I'm getting is "VIN is not a member of struct1". The
- > wh>code has been severely minimized, however this should have the bare
- > wh>essentials required to solve the problem.
- > wh>class CarData
- > wh>{
- > wh>private :
- > wh>char VIN[7];
- > wh>public :
- > wh>CarData(struct astruct1 CarInf);
- > wh>};
- > wh>//********************************************************
- > wh>CarData::CarData(struct astruct1 CarInf)
- > wh>{
- > wh>strcpy(VIN,CarInf.VIN);
- > wh>}
- > wh>struct astruct1
- > wh> {
- > wh> char VIN[7];
- > wh> }CarInfo;
- > wh>void main()
- > wh>{
- > wh>CarData CarConst1(struct astruct1 CarInfo);
- > wh>}
-
- > The key is 'private:' Using private restricts access to VIN
- > by any other part of your program except from within the object
- > (CarData)..
-
- Eh? The problem is CarData::CarData uses astruct1 before it's been
- defined so the compiler doesn't know VIN is a part of it.
-
- Moreover, main() tries to instantiate CarConst1 by passing it a
- type-declaration instead of an actual instance of astruct1.
-
-